package com.wanxi.service.impl;

import com.wanxi.dao.NewsclassificationDao;
import com.wanxi.model.NewsclassificationModel;
import com.wanxi.model.ResultModel;
import com.wanxi.service.NewsclassificationService;
import com.wanxi.util.SnowflakeIdWorker;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author 杨金乾
 */
@Service
public class NewsclassificationServiceImpl implements NewsclassificationService {
    @Autowired
    NewsclassificationDao newsclassificationDao;

    @Override
    public ResultModel enable(NewsclassificationModel newsclassificationModel) {
        return null;
    }

    @Override
    public ResultModel add(NewsclassificationModel newsclassificationModel) {
        SnowflakeIdWorker snowflakeIdWorker=new SnowflakeIdWorker(WorkId.WORK_ID);
        newsclassificationModel.setId(snowflakeIdWorker.nextId());
        return ResultModel.getResult(newsclassificationDao.add(newsclassificationModel));
    }

    @Override
    public ResultModel update(NewsclassificationModel newsclassificationModel) {
        return ResultModel.getResult(newsclassificationDao.update(newsclassificationModel));
    }

    @Override
    public ResultModel delete(NewsclassificationModel newsclassificationModel) {
        return ResultModel.getResult(newsclassificationDao.delete(newsclassificationModel));
    }

    @Override
    public ResultModel findById(NewsclassificationModel newsclassificationModel) {
        return ResultModel.getResult(newsclassificationDao.findById(newsclassificationModel));
    }

    @Override
    public ResultModel findAll(NewsclassificationModel newsclassificationModel) {

        return ResultModel.getResult(newsclassificationDao.findAll(newsclassificationModel), newsclassificationDao.count(newsclassificationModel));
    }

    @Override
    public ResultModel count(NewsclassificationModel newsclassificationModel) {
        return ResultModel.getResult(newsclassificationDao.count(newsclassificationModel));
    }

    @Override
    public ResultModel isShow(NewsclassificationModel newsclassificationModel) {
        return ResultModel.getResult(newsclassificationDao.isShow(newsclassificationModel));
    }

    @Override
    public ResultModel isRecommend(NewsclassificationModel newsclassificationModel) {
        return null;
    }

    @Override
    public ResultModel whereShow(NewsclassificationModel newsclassificationModel) {
        return null;
    }
}
